package com.aoxon.cargo.activity;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;

import com.aoxon.cargo.bean.GsonBean;
import com.aoxon.cargo.loader.NormalDataLoader;
import com.aoxon.cargo.util.DataUtil;
import com.google.gson.Gson;

public abstract class NewBaseActivity extends BaseActivity implements
		NormalDataLoader.OnLoadDataListener {
	private OnClickListener onClick;
	private NormalDataLoader loader;
	protected GsonBean gsonBean;
	protected Gson gson = DataUtil.gson;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(getLayoutId());
		onClick = new OnClickListener() {
			@Override
			public void onClick(View view) {
				// TODO Auto-generated method stub
				OnClickListener(view);
			}
		};
		loader = new NormalDataLoader(this);
		loader.setOnloadDataListener(this);
		setUI();
		
	}
	
	public final View findViewAndSetOnClick(int id) {
		View view = findViewById(id);
		view.setOnClickListener(onClick);
		return view;
	}

	public final void findViewAndSetOnClick(View view) {
		view.setOnClickListener(onClick);
	}
	
	public final void load(){
		loader.load();
	}

	public abstract int getLayoutId();

	public abstract void setUI();

	public abstract void OnClickListener(View view);
}
